'''
@project:pythonProjectT174
@auther:zhongyingjie
@file:selenium11.py
@date:2022/11/4 14:48
@desc:
'''
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
import unittest
from T174selenium.selenium_demo.common.broswersetting import broswersetting
from T174selenium.selenium_demo.elements.baidu_elements import *
class Baiduclj(broswersetting):

    def testxw(self):
        self._testMethodName='验证点击新闻是否正常跳转'
        # self._testMethodDoc='验证点击新闻是否正常跳转'
        # self.driver.find_element(By.LINK_TEXT,'新闻').click()
        self.baidu_news()
        time.sleep(2)
        x1=self.driver.window_handles
        self.driver.switch_to.window(x1[1])
        try:
            self.assertIn('新2闻', self.driver.title)
        except Exception as e:
            self.driver.get_screenshot_as_file('.\\images\\testxw.png')
            raise
    # def testdt(self):
    #     self.driver.find_element(By.LINK_TEXT, '地图').click()
    #     time.sleep(2)
    #     x2 = self.driver.window_handles
    #     self.driver.switch_to.window(x2[1])
    #     self.assertIn('地图', self.driver.title)
    def testhao123(self):
        self._testMethodName = '验证点击hao123是否正常跳转'
        # self._testMethodDoc = '验证点击hao123是否正常跳转'
        # self.driver.find_element(By.LINK_TEXT, 'hao123').click()
        self.baidu_hao123()
        time.sleep(2)
        x3 = self.driver.window_handles
        self.driver.switch_to.window(x3[1])
        try:
            self.assertIn('hao1234', self.driver.title)
        except Exception as e:
            self.driver.get_screenshot_as_file('.\\images\\testhao123.png')
            raise
    def testtb(self):
        self._testMethodName = '验证点击贴吧是否正常跳转'
        # self._testMethodDoc = '验证点击贴吧是否正常跳转'
        # self.driver.find_element(By.LINK_TEXT, '贴吧').click()
        self.baidu_tb()
        time.sleep(2)
        x4 = self.driver.window_handles
        self.driver.switch_to.window(x4[1])
        try:
            self.assertIn('贴吧', self.driver.title)
        except Exception as e:
            self.driver.get_screenshot_as_file('.\\images\\testtb.png')
            raise
if __name__=='__main__':
    unittest.main()